<!DOCTYPE html>
<html>
<head>
<title>文章分类管理</title>
[#include "/WEB-INF/admin/include/common.html"]
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>文章分类管理</h5>
            </div>
            <form id="listForm" action="list" method="get">
                <div class="ibox-content">
                    <!-- 搜索 start -->
                    <!-- 搜索 end -->
                    <!-- 列表 start -->
                    <div class="form-horizontal clear">
                        <div class="form-group">
                            <div class="col-sm-8">
                                <a class="btn btn-primary" href="add"><i class="fa fa-plus"></i> 添加</a>
                                <a href="javascript:;" class="btn btn-primary" id="refreshButton"><i class="fa fa-refresh"></i> 刷新</a>
                            </div>
                        </div>
                        <div class="table-responsive">
                            <table class="table table-bordered" id="listTable">
                                <thead>
                                    <tr>
                                        <th>ID</th>
                                        <th>名称</th>
                                        <th>排序</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    [#list articleCategoryTree as articleCategory]
                                    <tr>
                                        <td>${articleCategory.id}</td>
                                        <td>
                                            <span style="margin-left: ${articleCategory.grade * 20}px;[#if articleCategory.grade == 0] color: #000000;[/#if]">
						                        ${articleCategory.name}
						                    </span>
                                        </td>
                                        <td>${articleCategory.sort}</td>
                                        <td>
                                            <a href="edit?id=${articleCategory.id}">[编辑]</a>
                                            <a href="javascript:;" class="delete" val="${articleCategory.id}">[删除]</a>
                                        </td>
                                    </tr>
                                    [/#list]
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <!-- 列表 end -->
                </div>
            </form>
        </div>
    </div>
</body>
</html>
<script type="text/javascript">
$().ready(function() {

    var $delete = $("#listTable a.delete");
    
    // 删除
    $delete.click(function() {
        var $this = $(this);
        $.dialog({
            type: "warn",
            content: "您确定要删除吗？",
            onOk: function() {
                $.ajax({
                    url: "delete",
                    type: "POST",
                    data: {id: $this.attr("val")},
                    dataType: "json",
                    cache: false,
                    success: function(message) {
                    	if (message.type == "success") {
                            $this.closest("tr").remove();
                        }
                    }
                });
            }
        });
        return false;
    });

});
</script>